<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
</head>
<body class="gray-bg">
<div class="container creditbody">
	<div class="iboxtitle">
		<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷中业务>GPS加装</span>
		<a href="javascript:void(0)"></a>
	</div>
	<div class="buttonfixed">
       <button id="btnsave" class="btn dpbtn_blue" type="button" onclick="dosave();">保存</button>
    </div>
	<div class="ibox-content ibox-con">
		<%@include file="/jsp/comm_yw_info_include.jsp"%>
		<div class="business-manwife">GPS信息</div>
        <form class="form-horizontal" id="commentForm"> 
		<div class="insert-gps" id="insert-gps"> 
			<div class="business-padding">
				<input type="hidden" id="id" name="id"/>
				<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
					<tr>
						<td align="right">
							<label class="control-label np">安装时间：</label>
						</td>
						<td>
			           		<input id="timeInstall" name="timeInstall" class="laydate-icon form-control" placeholder="安装时间(必填)" required="required" onclick="laydate(this)" />
		           		</td>
		           		<td align="right">
			           		<label class="control-label np">安装人：</label>
		           		</td>
		           		<td>
			           		<input id="operatorInstall" required="required" name="operatorInstall" placeholder="安装人(必填)" class="form-control" />
		           		</td>
		           </tr>
	           		<tr>		
		           		<td align="right">
			           		<label class="control-label np">所属公司：</label>
		           		</td>
		           		<td>
			           		<select id="companyGps" name="companyGps" class="select-control" ></select>
		           		</td>
		           		<td align="right">
			           		<label class="control-label np">设备型号：</label>
		           		</td>
		           		<td>
			           		<input id="modelGps" name="modelGps" class="form-control" placeholder="设备型号" />
		           		</td>
		           	</tr>
	           		<tr>	
		           		<td align="right">
			           		<label class="control-label np">设备码：</label>
		           		</td>
		           		<td>
			           		<input id="keyGps" name="keyGps"  class="form-control" placeholder="GPS唯一编码(必填)" required="" aria-required="true"/>
		           		</td>
		           		<td align="right">
			           		<label class="control-label np">预计寿命(月)：</label>
		           		</td>
		           		<td>
			           		<input id="lifetimeGps" name="lifetimeGps" placeholder="预计寿命" class="form-control"  type="number" min="0"  aria-required="true"/>
		           		</td>
	           		</tr>
	           		<tr>
		           		<td align="right">
			           		<label class="control-label np">安装位置：</label>
		           		</td>
		           		<td colspan="3">
			           		<input id="locationInstall" name="locationInstall" class="form-control" placeholder="安装位置(必填)" required="required"/>
		           		</td>
					</tr>
				</table>
			</div>
		</div>	
	</form>
</div>	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>

    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    
    
    <!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
    $(function(){
		getGPSCompanyDic();
	 });
    
    var getGPSCompanyDic=function(){
    	$.dpAjax({
	    	url:'${basePath}/DataDictionaryController/getEnableList',
 			data:{
 				"parentValue":"GPSCompany"
 			},
 			success: function(datas){
 				  if(datas.flag == "100100")
					  {
	 					 var result = datas.result.rows;
						  var programme_sel=[];
					      for(var i=0;i<result.length;i++){
					          var programme = result[i];
					          programme_sel.push('<option value="'+programme.value+'">'+programme.name+'</option>')
					      }
						     $("#companyGps").html(programme_sel.join(' '));
						  return;
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
					  layer.msg(datas.message, {icon: 2});
              }
	    });
    }
    
	var allocation=function(data){
		$.dpAjax({
    		url:'${basePath}/DzGpsController/save',
    		data:data,
   			success: function(datas){
    			  if(datas.flag == "100100")
				  {
					  layer.msg('执行成功！', {icon: 6});
					  layer.close(layeroutb);
					  refresh();
					  return;
				  }
				  if(datas.flag == "100200")
                  {
					  $.fn.showDatas({"datas":datas});
                	  return;
                  }
                }
    	});
	}
	
   var dosave=function(){
	   var validstatus = $("#commentForm").valid();
   		if(validstatus){
			data={};
			data.timeInstall=$("#timeInstall").val();
			data.operatorInstall=$("#operatorInstall").val();
			data.companyGps=$("#companyGps option:selected").val(); 
			data.modelGps=$("#modelGps").val();
			data.keyGps=$("#keyGps").val();
			data.lifetimeGps=$("#lifetimeGps").val();
			data.locationInstall=$("#locationInstall").val();
			data.busiId=$.getUrlData("busiId");
			data.cusId=$.getUrlData("cusId");
			this.allocation(data);
   		}
   }
   
   var formateStringDate=function(sDate1){
    	if(!sDate1 || sDate1 == ''){
    		return '-';
    	}
    	var aDate  =  sDate1.substring(0,sDate1.lastIndexOf(" "))
    	return aDate;
    }
   
   $(function(){	
        $("#commentForm").validate({
            //重写showErrors
            showErrors: function (errorMap, errorList) {
                
                $.each(errorList, function (i, v) {
                    layer.tips(v.message, v.element, { time: 1500 });
                    return false;
                });  
            },
            /* 失去焦点时验证 */
            onfocusout: function(element) { $(element).valid(); },
            /*  键盘抬起不验证 */
            onkeyup:false,
        });
        
	})
    </script>
</body>
</html>
